#include "../../include/chat_tool.h"
void chatroom_tool::friend_apply_query(int fd,string data)
{
    string user_name,add_user;
    Json::Reader read;
    Json::Value te;
    if (!read.parse(data, te))
    {
        cout << "json格式错误3" << endl;
        return;
    }
    if (!te.isMember("user_name"))
    {
        cout << "json状态错误4" << endl;
        return;
    }
    else
    {
        user_name = te["user_name"].asString();
    }
    if(!te.isMember("add_user"))
    {
        cout<<"json状态错误"<<endl;
        return;
    }
    else
    {
        add_user=te["add_user"].asString();
    }
    string temp="insert into relationship values(null,'2','3','0')";
    add_user=Mysql.user_search(add_user);
    user_name=Mysql.user_search(user_name);
    temp.insert(38,user_name);
    temp.insert(41+user_name.size(),add_user);
    if(!Mysql.no_result(temp))
    {
        cout<<"好友请求发送失败"<<endl;
    }
}